package com.bw.order_module.confirm;

import android.os.Bundle;

import androidx.annotation.Nullable;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.bw.common.field.EventBusEntity;
import com.bw.common.mvvm.view.BaseActivity;
import com.bw.order_module.BR;
import com.bw.order_module.R;
import com.bw.order_module.databinding.ActivityConfirmOrderBinding;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

@Route(path = "/order/confirmactivity")
public class ConfirmActivity extends BaseActivity<ActivityConfirmOrderBinding,
        ConfirmViewModel> {

    @Override
    public int bindLayout() {
        return R.layout.activity_confirm_order;
    }

    @Override
    public int vrId() {
        return BR.vm;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        long orderId = getIntent().getBundleExtra("bundle").getLong("orderId",0l);
        vm.orderId = orderId;
        EventBus.getDefault().register(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void refreshOrder(EventBusEntity entity){
        if (entity.action.equals("refreshOrder")){
            vm.refreshOrderStatues();
        }
    }

}
